﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.ComponentModel;

namespace HA.ModFlow.Controls
{

    /// <summary>
    /// 主要用于同步绑定数据,为表现层类提供支持
    /// </summary>
   public class PCBase:INotifyPropertyChanged
    {



        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

       /// <summary>
       /// 对单元格的ID，I,J,K进行显示处理
       /// </summary>
       /// <param name="dtgrid"></param>
       /// <param name="isId">是否显示ID</param>
        public void isVisibleID(System.Windows.Controls.DataGrid dtgrid, bool isId)
        {
            if (dtgrid == null)
            {
                return;
            }
            if (isId)
            {
                foreach (System.Windows.Controls.DataGridTextColumn item in dtgrid.Columns )
                {
                    if (item.Header.ToString().Contains("单元格ID"))
                    {
                        item.Visibility =System.Windows.Visibility.Visible ;                       
                        continue;
                    }
                    if (item.Header.ToString().Contains("行"))
                    {
                        item.Visibility = System.Windows.Visibility.Collapsed;                      
                        continue;
                    }
                    if (item.Header.ToString().Contains("列"))
                    {
                        item.Visibility = System.Windows.Visibility.Collapsed;                     
                        continue;
                    }
                    if (item.Header.ToString().Contains("层"))
                    {
                        item.Visibility = System.Windows.Visibility.Collapsed;                     
                        continue;
                    }
                }
            }
            else
            {
                foreach (System.Windows.Controls.DataGridTextColumn item in dtgrid.Columns)
                {
                    
                    if (item.Header.ToString().Contains("单元格ID"))
                    {
                        item.Visibility = System.Windows.Visibility.Collapsed;                    
                        continue;
                    }
                    if (item.Header.ToString().Contains("行"))
                    {
                        item.Visibility = System.Windows.Visibility.Visible;                        
                        continue;
                    }
                    if (item.Header.ToString().Contains("列"))
                    {
                        item.Visibility = System.Windows.Visibility.Visible;                      
                        continue;
                    }
                    if (item.Header.ToString().Contains("层"))
                    {
                        item.Visibility = System.Windows.Visibility.Visible;                   
                        continue;
                    }
                }
            }
            for (int i = 4; i < dtgrid.Columns.Count; i++)
            {
                dtgrid.Columns[i].Width = System.Windows.Controls.DataGridLength.Auto;
            }
            dtgrid.CanUserSortColumns = false;
        }

    }
}
